package com.flower.enjoyment.flower.service.impl;

import com.flower.enjoyment.flower.entity.FlowerCardOrderDetail;
import com.flower.enjoyment.flower.entityDo.FlowerCardOrderDetailDo;
import com.flower.enjoyment.flower.mapper.FlowerCardOrderDetailMapper;
import com.flower.enjoyment.flower.service.FlowersCardOrderDetailService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class FlowersCardOrderDetailServiceImpl implements FlowersCardOrderDetailService {

    @Autowired
    private FlowerCardOrderDetailMapper flowerCardOrderDetailMapper;

    /**
     * 获取用户花享卡消费记录
     *
     * @param pageNo
     * @param pageSize
     * @param userId
     * @return
     */
    @Override
    public Page<FlowerCardOrderDetailDo> getFlowerCardOrderListByPage(Integer pageNo, Integer pageSize, String userId) {
        PageHelper.startPage(pageNo, pageSize);
        return flowerCardOrderDetailMapper.getFlowerCardOrderListByPage(userId);
    }

    /**
     * 新增花享卡消费记录
     *
     * @param flowerCardOrderDetail
     * @return
     */
    @Override
    @Transactional
    public int insertFlowerCardOrderDetail(FlowerCardOrderDetail flowerCardOrderDetail) {
        return flowerCardOrderDetailMapper.insert(flowerCardOrderDetail);
    }
}
